1. Technology Field
The invention generally relates to a data writing method, and more particularly, to a data writing method for a non-volatile memory module with a large number of bad physical blocks and a memory controller and a memory storage apparatus using the same.
2. Description of Related Art
Rewritable non-volatile memory is one of the most adaptable storage media to electronic devices due to its characteristics such as data non-volatility, low power consumption, small volume, non-mechanical structure, and high access speed. A solid state drive (SSD) is a storage device which uses a NAND flash memory as its storage medium. Flash memory has broadly adopted for storing important personal data thanks to its small volume and large storage capacity. Thereby, the flash memory industry has become a very important part of the electronic industry in recent years.
Generally speaking, in a rewritable non-volatile memory storage apparatus, the physical blocks in the re-writable non-volatile memory module are logically grouped by the memory controller into a data area, a free area, a system area, and a replacement area.
The physical blocks in the data area have stored data and the physical blocks in the free area are used for substituting the physical blocks in the data area when the write commands are executed. To be specific, when a rewritable non-volatile memory storage apparatus receives a write command from a host system and is about to update data in a physical block of the data area, the rewritable non-volatile memory storage apparatus selects a physical block from the free area, writes the valid old data stored in the physical block to be updated in the data area and the new data into the physical block selected from the free area, associates the physical block containing the new data with the data area, and erases the original physical block in the data area and associates the erased physical block with the free area. In order to allow the host system to successfully access the physical blocks that are alternatively used for storing data, the rewritable non-volatile memory storage apparatus configures logical sectors to be accessed by the host system, wherein the logical sectors are grouped into a plurality of logical pages, and the logical pages are grouped into a plurality of logical block. In particular, the rewritable non-volatile memory storage apparatus establishes a logical block-physical block mapping table and records and updates the mapping relationship between the logical blocks and the physical blocks of the data area in the logical block-physical block mapping table, so as to reflect the alternation of the physical blocks. Accordingly, the host system simply accesses the logical sectors, while the rewritable non-volatile memory storage apparatus actually reads data from or writes data into the corresponding physical blocks according to the logical block-physical block mapping table.
The physical blocks in the system area are used for storing important information related to the rewritable non-volatile memory storage apparatus, and the physical blocks in the replacement area are used for replacing damaged physical blocks (i.e., bad physical blocks) in the system area, the data area, or the free area. To be specific, in an existing block management technique, when data written into a physical page or a physical sector of a physical block contains error bits that cannot be corrected through an error checking and correcting procedure, the physical block is marked as a bad physical block, and the memory controller selects a physical block from the replacement area to replace the bad physical block. In addition, when there are not enough normal physical blocks in the re-writable non-volatile memory module for writing data in the alternative manner described above, the rewritable non-volatile memory storage apparatus can no longer be used for writing data.
Due to the limitation in the manufacturing process, some physical sectors of physical blocks of a re-writable non-volatile memory module may have defects therefore cannot be used for storing data. These physical blocks are identified as bad physical blocks and will not be used. In particular, if a rewritable non-volatile memory storage apparatus cannot work properly due to the large number of bad physical blocks therein, the re-writable non-volatile memory module is considered a defective and unusable product. However, in fact, there is still a large quantity of normal storage space that can be used for storing data in such bad physical blocks. Thus, the re-writable non-volatile memory module that is considered as defective product during the manufacturing process can be reused if these defective physical blocks can be effectively used.
Nothing herein should be construed as an admission of knowledge in the prior art of any portion of the present invention. Furthermore, citation or identification of any document in this application is not an admission that such document is available as prior art to the present invention, or that any reference forms a part of the common general knowledge in the art.